clear

set more off

*If necessary: install catplot
*ssc install catplot

*

import excel "/Users/cmailhot/Desktop/Replication of Mailhot and Karim. International Statebuilding and Civilian Preferences. IO/Round 2.xlsx", sheet("Sheet1") firstrow 

egen id = seq()

order id

label define response_category 1 "Does nothing to help" 2 "Helps a little bit"  3 "Helps a fair bit"  4 "Helps a lot" 98 "I don't know"  99 "Prefer not to say"


label values unmil_unhelp response_category
label values unmil_ushelp response_category
label values unmil_chinahelp response_category

rename unmil_unhelp combo_unmil_unhelp
rename unmil_ushelp combo_unmil_ushelp
rename unmil_chinahelp combo_unmil_chinahelp

reshape long combo_,  i(id) j(help_source) string

*Figure 3 (Main manuscript) 
catplot, over1(help_source) over2(combo_) percent(help_source) asyvars recast(bar) blabel(bar, format(%4.1fc)) play("/Users/cmailhot/Desktop/Replication of Mailhot and Karim. International Statebuilding and Civilian Preferences. IO/Figure 3.grec")
clear


**
**
**

clear

set more off

import excel "/Users/cmailhot/Desktop/Replication of Mailhot and Karim. International Statebuilding and Civilian Preferences. IO/Round 2.xlsx", sheet("Sheet1") firstrow 

egen id = seq()

order id

label define response_category 1 "Not at all" 2 "Just a little"  3 "Somewhat"  4 "A Lot" 98 "I don't know"  99 "Prefer not to say"

label values pol_trustun response_category
label values pol_trustus response_category
label values pol_trustchina response_category

label values pol_trustpres response_category

rename pol_trustun combo_pol_trustun
rename pol_trustus combo_pol_trustus
rename pol_trustchina combo_pol_trustchina

rename pol_trustpres combo_pol_trustpres

reshape long combo_,  i(id) j(help_source) string

*Figure A2 (appendix)
catplot, over1(help_source) over2(combo_) percent(help_source)  asyvars recast(bar) blabel(bar, format(%4.1fc)) play("/Users/cmailhot/Desktop/Replication of Mailhot and Karim. International Statebuilding and Civilian Preferences. IO/FigureA2.grec") 


clear 


**
**
**

clear

set more off

import excel "/Users/cmailhot/Desktop/Replication of Mailhot and Karim. International Statebuilding and Civilian Preferences. IO/Round 2.xlsx", sheet("Sheet1") firstrow 


*create democratic traditions variable

gen  authoritarianscale1  =  dem_traditions  
replace   authoritarianscale1   = . if ( dem_traditions   ==98 )
replace   authoritarianscale1   = . if ( dem_traditions   ==99 )	

gen  authoritarianscale2  =  dem_punishment  
replace   authoritarianscale2   = . if ( dem_punishment   ==98 )
replace   authoritarianscale2   = . if ( dem_punishment   ==99 )

gen  authoritarianscale3  =  dem_leaders  
replace   authoritarianscale3   = . if ( dem_leaders   ==98 )
replace   authoritarianscale3   = . if ( dem_leaders   ==99 )

gen  authoritarianscale4  =  dem_radical  
replace   authoritarianscale4   = . if ( dem_radical   ==98 )
replace   authoritarianscale4   = . if ( dem_radical   ==99 )
	

	
*Authoritarian Index 
gen authoritarian = authoritarianscale1 + authoritarianscale2 + authoritarianscale3 + authoritarianscale4




gen   talktounmilfreq   =  until_talkbefore 
replace   talktounmilfreq   = . if ( until_talkbefore  ==98 )
replace   talktounmilfreq   = . if ( until_talkbefore  ==99 )


gen supportcurrentparty = pol_party
replace   supportcurrentparty   = 0 if ( pol_party  ==1 )
replace   supportcurrentparty   = . if ( pol_party  ==2 )
replace   supportcurrentparty   = . if ( pol_party  ==3 )
replace   supportcurrentparty   = . if ( pol_party  ==4 )
replace   supportcurrentparty   = . if ( pol_party  ==5 )
replace   supportcurrentparty   = . if ( pol_party  ==6 )
replace   supportcurrentparty   = . if ( pol_party  ==7 )
replace   supportcurrentparty   = . if ( pol_party  ==8 )
replace   supportcurrentparty   = . if ( pol_party  ==9 )
replace   supportcurrentparty   = . if ( pol_party  ==10 )
replace   supportcurrentparty   = . if ( pol_party  ==11 )
replace   supportcurrentparty   = 1 if ( pol_party  ==12 )
replace   supportcurrentparty   = 0 if ( pol_party  ==0 )
replace   supportcurrentparty   = 0 if ( pol_party  ==99 )


* 
gen single = 0 
replace single = 1 if back_maritalstat == 5
replace single = . if ( back_maritalstat   ==98 )
replace single = . if ( back_maritalstat   ==99 )

* 
gen internet = 1
replace internet = 0 if back_internet == 0

replace internet = . if ( back_internet   ==98 )
replace internet = . if ( back_internet   ==99 )

* 
gen back_income2 = back_income
replace back_income2 = . if back_income2   ==99 | back_income2 == 98

*
gen back_live20032 = back_live2003
replace back_live20032 = . if back_live20032   ==99 | back_live20032 == 98

*
gen back_hhousehold2 = back_hhousehold
replace back_hhousehold2 = . if back_hhousehold2   ==99 | back_hhousehold2 == 98

*
gen back_education2 = back_education
replace back_education2 = . if back_education2   ==99 | back_education2 == 98

*
gen dr_victim2 = dr_victim
replace dr_victim2 = . if dr_victim2   ==99 | dr_victim2 == 98

*
gen minority = 1
replace minority = 0 if back_ethnicity == 9 
replace minority = . if minority   ==99 | minority == 98

* 
gen dr_armedgroups2 = dr_armedgroups
replace dr_armedgroups2 = . if dr_armedgroups2   ==99 | dr_armedgroups2 == 98

* 
gen HeadOfHousehold = back_hhousehold
replace HeadOfHousehold = . if HeadOfHousehold == 99

*
gen  trustchina  =  pol_trustchina  
replace   trustchina   = . if ( pol_trustchina   ==98 )
replace   trustchina   = . if ( pol_trustchina   ==99 )

estimates clear
regress trustchina  authoritarian i.dr_armedgroups2 i.supportcurrentparty talktounmilfreq i.town_name i.back_sex back_age i.single i.minority back_income2 i.internet i.back_ownstuff_Radio i.back_live20032 i.HeadOfHousehold back_numhousehol back_education2
eststo chinaregression

*Table A17 (appendix)
esttab chinaregression  using /Users/cmailhot/Desktop/ChinaTrustRegression.tex, b(2) se(2) stats(N aic p) noconstant replace


clear

